<?php
my_component_load('testing' , false);
my_component_load('paging' , false);
my_component_load('hobi');
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;
$kid = isset( $_GET['kid'] ) ? $_GET['kid']:  0;

if($_SERVER['REQUEST_METHOD'] == "POST" ):
	switch($task){
		case   "create" :
			form_submit_data_hobi($id);
			my_direct( 'index.php?com='.$_GET['com'].'&task=detail_entry_karyawan&id='.$id );
		break;
		case   "edit" :
			form_edit_data_hobi_submit($id);
			my_direct( 'index.php?com=karyawan&task=detail&id='.$id );
		break;
		case   "edit_page" :
			form_edit_data_each_hobi_submit($id);
			$content="Updated";
			generate_my_web($content, $pagename ,'plain.php' );
			exit;
		break;
	}

else: 	
	$_SESSION['tab_page'] = '#tab6';
	if($task == "create"){
		$pagename = "Riwayat kesehatan";
		$content = form_create_data_hobi();
	}elseif($task == "edit"){
		$pagename = "Edit data kesehatan kekaryawan";
		$content = form_edit_data_hobi($id); 
	}elseif($task == "detail_entry_karyawan"){ 
		$karyawan = loaddata_karyawan($id);
		$pagename = "Detail data kesehatan karyawan ".$karyawan['nama'];
		$content = entry_detail_hobi($id);
	}elseif($task == "edit_page"){ 
		$content  = form_edit_data_each_hobi( $id );
		generate_my_web($content,"","plain.php");
		exit;		
	}elseif($task == 'edit_popup'){	
		$title= ($aid > '0' ) ?  "Perubahan data hobi" : "Tambah data hobi";
		facebox_page('index.php?com=hobi&task=edit_page&kid='.$kid.'&id='.$id  , $title , 210	); 
			
	}else{
		$pagename = "Daftar hobi";
		load_facebox_script();
		$content = report_karyawan();
	}
endif; 
generate_my_web($content, $pagename  );
?>